package scu.maqiang.mesh.test;

import scu.maqiang.mesh.Mesh3T4;
import scu.maqiang.mesh.MeshFormat;
import scu.maqiang.numeric.MVO;
import scu.maqiang.numeric.UnorderIntArray;

import java.util.HashSet;

public class TetrahedronFaces {
    public static void main(String[] args) {
        Mesh3T4 mesh = new Mesh3T4().cube(2,2, 2);
        mesh.saveMesh(MeshFormat.msh, "Cube222.msh");
        HashSet<UnorderIntArray> set = mesh.extractEdgesFromElements();
		UnorderIntArray[] edgesSet = new UnorderIntArray[set.size()];
		set.toArray(edgesSet);
		int[][] edges = new int[edgesSet.length][];
		for(int i = 0; i < edgesSet.length; i++) {
			edges[i] = edgesSet[i].getIntSet();
		}
        MVO.saveMatrix("Edges222.txt", edges);
		int[][] edgeElement = mesh.elementsToEdges();
		MVO.saveMatrix("EdgeElements222.txt", edgeElement);
//        HashSet<UnorderIntArray> set = mesh.extractEdgesFromElements();
//        mesh.displayNodes();
//        mesh.displayElements();
//        mesh.displayBoundarys();
//        System.out.println(set.size());
//        for(UnorderIntArray ele: set) {
//            System.out.println(ele);
//        }
//        System.out.println("=====================");
//        int[] idxes = new int[set.size()];
//        Arrays.setAll(idxes, i -> i);
//        UnorderIntArray[] edgesSet = new UnorderIntArray[set.size()];
//        set.toArray(edgesSet);
//        for(int i = 0; i < set.size(); i++) {
//            System.out.println(edgesSet[i]);
//        }

//        int[][] edgeElement = mesh.elementsToEdges();
//        for(int i = 0; i < mesh.getNt(); i++) {
//            System.out.println(Arrays.toString(edgeElement[i]));
//        }


    }
}
